package cn.study.zgm.nettyall.selector.selector;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * packageName cn.study.zgm.nettyall.selector.selector
 *
 * @author 你的名字
 * @version JDK 8
 * @className Client (此处以class为例)
 * @date 2025/2/25
 * @description TODO
 */
@Slf4j
public class Client {
    public static void main(String[] args) throws IOException {
        final SocketChannel sc = SocketChannel.open();
        sc.configureBlocking(false);
        sc.connect(new InetSocketAddress("127.0.0.1",8081));
        log.info("客户端[{}]连接到服务器",sc);
        log.info("----------------------------");
        final ByteBuffer byteBuffer = ByteBuffer.allocate(300000);
        long count = 0;
        long length = 0;
        while ((length = sc.read(byteBuffer)) >0){
            byteBuffer.clear();
            count+=length;
            System.out.println(count);
        }
    }
}
